package com.sky.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {
    
    @Bean
    public ThreadPoolExecutor recommendationThreadPool() {
        return new ThreadPoolExecutor(
                2,                      // 核心线程数
                4,                      // 最大线程数
                60,                     // 空闲线程存活时间
                TimeUnit.SECONDS,       // 时间单位
                new ArrayBlockingQueue<>(100),  // 工作队列
                new ThreadPoolExecutor.CallerRunsPolicy()  // 拒绝策略
        );
    }
} 